home *** CD-ROM | disk | FTP | other *** search
/ IRIX Base Documentation 1998 November / IRIX 6.5.2 Base Documentation November 1998.img / usr / share / catman / p_man / cat3 / f90 / cvmg.z / cvmg
Text File  |  1998-10-30  |  7KB  |  168 lines

  1. CVMG(3I)                                               Last changed: 1-6-98
  2.  
  3.  
  4. NNAAMMEE
  5.      CCVVMMGGMM, CCVVMMGGNN, CCVVMMGGPP, CCVVMMGGTT, CCVVMMGGZZ - Conditional vector merge functions
  6.  
  7. SSYYNNOOPPSSIISS
  8.      CCVVMMGGMM (([II==]_i,, [JJ==]_j,, [KK==]_k))
  9.  
  10.      CCVVMMGGNN (([II==]_i,, [JJ==]_j,, [KK==]_k))
  11.  
  12.      CCVVMMGGPP (([II==]_i,, [JJ==]_j,, [KK==]_k))
  13.  
  14.      CCVVMMGGTT (([II==]_i,, [JJ==]_j,, [KK==]_k))
  15.  
  16.      CCVVMMGGZZ (([II==]_i,, [JJ==]_j,, [KK==]_k))
  17.  
  18. IIMMPPLLEEMMEENNTTAATTIIOONN
  19.      UNICOS, UNICOS/mk, and IRIX systems
  20.  
  21. SSTTAANNDDAARRDDSS
  22.      CF90 and MIPSpro 7 Fortran 90 compiler extension to Fortran 90
  23.  
  24. DDEESSCCRRIIPPTTIIOONN
  25.      At run time, _k is tested.  You can use the conditional vector merge
  26.      (CVMG) functions when an IIFF statement involving arrays prevents
  27.      vectorization of a loop.  The compiler can vectorize almost all such
  28.      loops, but these functions can be used in older codes.  Scalar
  29.      arguments can also be used with these functions.
  30.  
  31.      CVMG functions cannot be passed as arguments.  They are elemental
  32.      functions.
  33.  
  34.      These functions test for the following:
  35.  
  36.      * CCVVMMGGMM tests for minus (negative).  _i is returned if _k < 0.  _j is
  37.        returned if _k >= 0.
  38.  
  39.      * CCVVMMGGNN tests for nonzero.  _i is returned if _k is not equal to 0.  _j
  40.        is returned if _k = 0.
  41.  
  42.      * CCVVMMGGPP tests for positive or zero.  _i is returned if _k >= 0.  _j is
  43.        returned if _k < 0.
  44.  
  45.      * CCVVMMGGTT tests for true.  _i is returned if _k is true.  _j is returned if
  46.        _k is false.
  47.  
  48.      * CCVVMMGGZZ tests for zero.  _i is returned if _k = 0.  _j is returned if _k
  49.        is not equal to 0.
  50.  
  51.      These functions accept the following arguments:
  52.  
  53.      _i     Can be of type logical, Boolean, integer, real, or Cray pointer.
  54.  
  55.            See the RETURN VALUES section of this man page for more
  56.            information on how the type of _i affects the return value.
  57.  
  58.      _j     Can be of type logical, Boolean, integer, real, or Cray pointer.
  59.  
  60.            See the RETURN VALUES section of this man page for more
  61.            information on how the type of _j affects the return value.
  62.  
  63.      _k     Can be of type logical, Boolean, integer, real, or Cray pointer.
  64.  
  65.            See the RETURN VALUES section of this man page for more
  66.            information on how the type of _k affects the return value.
  67.  
  68.      If _k satisfies the condition tested by the function (for example, in
  69.      CCVVMMGGPP, if _k is positive), the first argument (_i) is returned as the
  70.      function result.  If _k does not satisfy the condition tested by the
  71.      function, _j is returned as the function result.
  72.  
  73.      For operands other than type logical, the vector merge functions are
  74.      not generic with respect to data typing.  They accept arithmetic
  75.      values of different types but interpret them as Boolean type (that is,
  76.      as bit patterns).  The returned function value is also Boolean.
  77.      Therefore, the function reference CCVVMMGGTT((11..00,,22..00,,..TTRRUUEE..)) is not type
  78.      real, with a value of 1.0, but a Boolean value that acts the same as
  79.      1.0 in a floating-point operation.
  80.  
  81.      A problem can arise if you assume that the function reference is type
  82.      real and use it in an expression or assignment that causes automatic
  83.      type conversion.  For example, if you use the function reference in a
  84.      context where an integer is needed, the result is not valid because
  85.      1.0 and 1 have different bit patterns.
  86.  
  87.      Because CVMG function values are Boolean, a binary operation involving
  88.      two CVMG functions uses integer arithmetic.  This can produce
  89.      unexpected results in assignments such as the following in which AA, BB,
  90.      CC, and DD are real:
  91.  
  92.           X = CVMGT(A,B,LOGIC1) + CVMGT(C,D,LOCIC2)
  93.                          ! Integer arithmetic, invalid results
  94.  
  95.      However, when used in an expression with another operand, a CVMG
  96.      function value takes on the type of the other operand, without any
  97.      explicit type conversion.  For example, the following expression uses
  98.      real arithmetic:
  99.  
  100.           X = 1.0 + CVMGT(2.0,3.0,LEXP)  ! Valid (types agree)
  101.  
  102.      The following suggestions explain how to prevent bugs when using these
  103.      functions:
  104.  
  105.      * Use only one CVMG function in a given expression.  If you use more
  106.        than one CVMG function in an expression, use explicit type
  107.        conversion.  This does not generate any additional code.  For
  108.        example:
  109.  
  110.           X = REAL(CVMGT(1.0,2.0,LTEST)) + REAL(CVMGT(X,Y,LTEST2))
  111.  
  112.      * Ensure that the assignment type matches the function argument.
  113.        Example:
  114.  
  115.          X = CVMGT(1.0,2.0,LTEST) ! Valid
  116.          X = REAL(CVMGT(1,2,LTEST)) ! Valid (uses explicit type conversion)
  117.          X = CVMGT(1,2,LTEST) ! Invalid (type mismatch)
  118.  
  119.      * Never use mixed typing in the first two arguments of a CCVVMMGGTT
  120.        function.  Example:
  121.  
  122.           CVMGT(1,2.0,LTEST)  ! DO NOT DO THIS
  123.  
  124.      The names of these intrinsics cannot be passed as arguments.
  125.  
  126. NNOOTTEESS
  127.      The CVMG intrinsic functions are outmoded.  Refer to the _F_o_r_t_r_a_n
  128.      _L_a_n_g_u_a_g_e _R_e_f_e_r_e_n_c_e _M_a_n_u_a_l, _V_o_l_u_m_e _3, publication SR-3905, for
  129.      information on outmoded features and their preferred standard
  130.      alternatives.
  131.  
  132. RREETTUURRNN VVAALLUUEESS
  133.      For CCVVMMGGMM, CCVVMMGGNN, CCVVMMGGPP, CCVVMMGGTT, and CCVVMMGGZZ, the return value is either
  134.      type Boolean, logical, integer, or real, depending on the type of _i
  135.      and jj.
  136.  
  137.      On UNICOS and UNICOS/mk systems, type logical is returned if _i is of
  138.      type logical; otherwise it is of type Boolean.
  139.  
  140.      On IRIX systems, if _i and _j are both of type real, the result type is
  141.      also real.  If _i is of type logical, type logical is returned.  In all
  142.      other cases, the return value is of type integer.
  143.  
  144. EEXXAAMMPPLLEESS
  145.      Consider the following code:
  146.  
  147.           DO I = N,M
  148.              X(I) = A(I)
  149.              IF (B(I) .GT. C(I)) X(I) = D(I)
  150.           END DO
  151.  
  152.      This could be rewritten as follows:
  153.  
  154.           DO  I = N,M
  155.              X(I) = CVMGT(D(I), A(I), B(I).GT.C(I))
  156.           END DO
  157.  
  158.      The following rewrite would also be valid:
  159.  
  160.           DO I = N,M
  161.              X(I) = CVMGP( D(I), A(I), B(I) - C(I))
  162.           END DO
  163.  
  164. SSEEEE AALLSSOO
  165.      _I_n_t_r_i_n_s_i_c _P_r_o_c_e_d_u_r_e_s _R_e_f_e_r_e_n_c_e _M_a_n_u_a_l, publication SR-2138, for the
  166.      printed version of this man page.
  167.  
  168.